﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DemoUserControl.Form_Control;

namespace DemoUserControl
{
    public partial class MainMenu : Form
    {
        Form1 frm1 = new Form1();
        Form2 frm2 = new Form2();
        Form3 frm3 = new Form3();
        Form4 frm4 = new Form4();
        Form5 frm5 = new Form5();
        treeView TV = new treeView();
         
        public MainMenu()
        {
            InitializeComponent();
            TV.loadTreeView += new treeView.customHandler(SetTreeViewNode);
            #region "load add form as panel"
            showControl_TabPage_1(frm1);
            showControl_TabPage_2(frm2);
            showControl_TabPage_3(frm3);
            showControl_TabPage_4(frm4);
            showControl_TabPage_5(frm5);
            showControl_TabPage_TreeView(TV);
            #endregion
        }
        #region "add form as panel"
        public void showControl_TabPage_1(System.Windows.Forms.Control obj)
        {
            panel_form1.Controls.Clear();
            obj.Dock = DockStyle.Fill;
            panel_form1.Controls.Add(obj);
            panel_form1.Controls[obj.Name].Focus();
        }
        public void showControl_TabPage_2(System.Windows.Forms.Control obj)
        {
            panel_form2.Controls.Clear();
            obj.Dock = DockStyle.Fill;
            panel_form2.Controls.Add(obj);
            panel_form2.Controls[obj.Name].Focus();
        }
        public void showControl_TabPage_3(System.Windows.Forms.Control obj)
        {
            panel_form3.Controls.Clear();
            obj.Dock = DockStyle.Fill;
            panel_form3.Controls.Add(obj);
            panel_form3.Controls[obj.Name].Focus();
        }
        public void showControl_TabPage_4(System.Windows.Forms.Control obj)
        {
            panel_form4.Controls.Clear();
            obj.Dock = DockStyle.Fill;
            panel_form4.Controls.Add(obj);
            panel_form4.Controls[obj.Name].Focus();
        }
        public void showControl_TabPage_5(System.Windows.Forms.Control obj)
        {
            panel_form5.Controls.Clear();
            obj.Dock = DockStyle.Fill;
            panel_form5.Controls.Add(obj);
            panel_form5.Controls[obj.Name].Focus();
        }
        public void showControl_TabPage_TreeView(System.Windows.Forms.Control obj)
        {
            panel_treeView.Controls.Clear();
            obj.Dock = DockStyle.Fill;
            panel_treeView.Controls.Add(obj);
            panel_treeView.Controls[obj.Name].Focus();
        }
        #endregion        
        private void MainMenu_Load(object sender, EventArgs e)
        {
            TV.Add_TreeNode();
        }
        void SetTreeViewNode(object sender, string i, string a)
        {
            if (i != "")
            {                
                frm1.Bien = i +" " +a;
                frm1.LoadTable();
                frm1.load();
            }
            
        }
    }
}
